import pika

from utils import get_connection

# 建立socket连接
connection = get_connection()
# 建立rabbitMQ协议的通道
channel = connection.channel()
# 声明队列：通过通道申明队列
channel.queue_declare(queue="abc")
# 发送、发布消息：routing_key--队列名称，body--消息
channel.basic_publish(
    exchange="topic_logs",
    routing_key="abc",
    body="hello rabbotmq!"
)
print("[x] sent a message.")
# 关闭socket连接
connection.close()
